#include <iostream>
#include <stack>
#include <vector>

using namespace std;

vector<int> dailyTemperatures(vector<int>& temperatures) {
    int n = temperatures.size();
    vector<int> ret(n, 0);
    stack<int> st;

    for (int i = 0; i < n; ++i)
    {
        while (!st.empty() && temperatures[i] > temperatures[st.top()])
        {
            ret[st.top()] = i - st.top();
            st.pop();
        }
        st.push(i);
    }

    return ret;
}

int main()
{
    vector<int> ret = { 73,74,75,71,69,72,76,77  };
    dailyTemperatures(ret);
	return 0;
}